<template>
	<view>
		<!-- 顶部导航栏 -->
		<cu-custom bgColor="bg-gradual-green">
			<block slot="content">我的课程</block>
		</cu-custom>
		
		<message ref="message"></message>
		
		<!-- 课程列表 -->
		<course-list-item :course="item" v-for="(item, index) in myList" :key="index"></course-list-item>
		
	</view>
</template>

<script>
	import CourseListItem from "@/components/course-list-item/course-list-item.vue"
	import { getStudentCourse } from "@/api/course.js"
	import { parseTime } from "@/utils/parse.js"
	
	export default {
		components:{
			CourseListItem
		},
		data() {
			return {
				myList: []
			}
		},
		created() {
			if(!uni.getStorageSync('token')){
				uni.navigateTo({
					url: "/pages/login/login"
				})
			}
			this.getCourseList()
		},
		onShow() {
		},
		computed:{
			
		},
		methods: {
			parseTime,
			// 获取我的课程列表
			getCourseList(){
				getStudentCourse().then(res => {
					this.myList = res.data
				})
			}
		}
	}
</script>

<style>

</style>
